package com.jf.blog;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/*默认的启动配置*/
//@SpringBootApplication
/*排除Spring自带的数据源进行启动*/
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@MapperScan("com.jf.blog.mapper")
@Slf4j
public class BlogApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(BlogApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path", "");

        log.info("\n----------------------------------------------------------\n" +
                "Application is running! Access URLs:\n" +
                "Local: \t\thttp://localhost:" + port + path + "\n" +
                "External: \thttp://" + ip + ":" + port + path + "\n" +
                "----------------------------------------------------------");

    }

}
